﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderInfoList.aspx.cs"
    Inherits="CRM.WEB.OrderInfoList" %>

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Fit Layout</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="Static/jquery-1.6.2.min.js" type="text/javascript"></script>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link href="/Static/demo.css" rel="stylesheet" type="text/css" />
    <script src="/Static/boot.js" type="text/javascript"></script>
    <link href="Static/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        html, body
        {
            margin: 0;
            padding: 0;
            border: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <%--  <td style="width: 100%;">
                    <a class="mini-button" iconcls="icon-save" plain="true">保存</a> <a class="mini-button"
                        iconcls="icon-close" plain="true">关闭</a> <span class="separator"></span><a class="mini-button"
                            iconcls="icon-reload" plain="true">刷新</a>
                </td>--%>
                <td style="width: 90%;">
                    <label style="font-family: Verdana;">
                        定单编号:
                    </label>
                    <input class="mini-textbox" id="txt_OrderNO" />
                    <label style="font-family: Verdana;">
                        保证书编号:
                    </label>
                    <input class="mini-textbox" id="txt_GuaranteeNO" />
                    <label style="font-family: Verdana;">
                        购买人:
                    </label>
                    <input class="mini-textbox" id="txt_BuyerFullName" />
                    <label style="font-family: Verdana;">
                        定单时间:
                    </label>
                    <input class="mini-datepicker" id="txt_OrderDate" />
                    <label style="font-family: Verdana;">
                        是否可用:
                    </label>
                    <input id="txt_IsDel" shownullitem="true" class="mini-combobox" textfield="text"
                        valuefield="id" url="ConfigData/isActived.txt" allowinput="false" emptytext="请选择是否可用" />
                    <a class="mini-button" iconcls="icon-search" onclick="search()">查询</a> <a class="mini-button"
                        iconcls="icon-remove" onclick="clear()">清空条件</a>
                </td>
                <td style="width: 5%;">
                    <a class="mini-button" iconcls="icon-save" onclick="ExportExcel()">导出</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" url="Ajax/AjaxService.aspx?method=GetOrderInfo"
        idfield="OrderNO" sizelist="[5,10,20,50]" pagesize="10">
        <div property="columns">
            <div type="indexcolumn">
            </div>
            <div field="OrderNO" width="120" headeralign="center" allowsort="true">
                OrderNO</div>
            <div field="GuaranteeNO" width="120" headeralign="center" allowsort="true">
                GuaranteeNO</div>
            <div field="BuyerID" width="100" align="center" headeralign="center">
                BuyerID
            </div>
            <div field="BuyerFullName" width="100" allowsort="true">
                BuyerFullName</div>
            <div field="BuyerAdd" width="100" allowsort="true">
                BuyerAdd</div>
            <div field="BuyerTel" width="100" headeralign="center" dateformat="yyyy-MM-dd" allowsort="true">
                BuyerTel</div>
            <div field="OrderDate" width="120" headeralign="center" allowsort="true" dateformat="yyyy-MM-dd"
                allowsort="true">
                OrderDate</div>
            <div field="DeliveryDate" width="120" headeralign="center" allowsort="true" dateformat="yyyy-MM-dd"
                allowsort="true">
                DeliveryDate</div>
            <div field="ProductTitle" width="120" headeralign="center" allowsort="true">
                ProductTitle</div>
            <div field="ProductModel" width="120" headeralign="center" allowsort="true">
                ProductModel</div>
            <div field="ProductBrand" width="120" headeralign="center" allowsort="true">
                ProductBrand</div>
            <div field="RAM" width="120" headeralign="center" allowsort="true">
                RAM</div>
            <div field="ROM" width="120" headeralign="center" allowsort="true">
                ROM</div>
            <div field="Network4G" width="120" headeralign="center" allowsort="true">
                Network4G</div>
            <div field="Band4G" width="120" headeralign="center" allowsort="true">
                Band4G</div>
            <div field="Network3G" width="120" headeralign="center" allowsort="true">
                Network3G</div>
            <div field="Band3G" width="120" headeralign="center" allowsort="true">
                Band3G</div>
            <div field="Network2G" width="120" headeralign="center" allowsort="true">
                Network2G</div>
            <div field="Band2G" width="120" headeralign="center" allowsort="true">
                Band2G</div>
        </div>
        </div>
        <iframe id="exportIFrame" style="display: none;"></iframe>
        <!--导出Excel相关HTML-->
        <form id="excelForm" action="Ajax/export.aspx?type=excel" method="post" target="excelIFrame">
        <input type="hidden" name="columns" id="excelData" />
        <input type="hidden" name="orderNO" id="orderNOHidden" />
        <input type="hidden" name="guaranteeNO" id="guaranteeNOHidden" />
        <input type="hidden" name="buyerFullName" id="buyerFullNameHidden" />
        <input type="hidden" name="orderDate" id="orderDateHidden" />
        <input type="hidden" name="isDel" id="isDelHidden" />
        </form>
        <iframe id="excelIFrame" name="excelIFrame" style="display: none;"></iframe>
        <script type="text/javascript">
            mini.parse();
            var grid = mini.get("datagrid1");
            grid.sortBy("OrderDate", "DESC");
            grid.load();


            mini.get("txt_OrderDate").setAllowInput(false);
            function unfixColumns() {
                grid.unFrozenColumns();
            }
            function fixColumns() {
                grid.frozenColumns(0, 1);
            }
            //去空格
            function trimStr(str) {
                return str.replace(/(^\s*)|(\s*$)/g, "");
            }
            //清空条件
            function clear() {
                mini.get("txt_OrderNO").setValue("");
                mini.get("txt_GuaranteeNO").setValue("");
                mini.get("txt_BuyerFullName").setValue("");
                mini.get("txt_OrderDate").setValue("");
                mini.get("txt_IsDel").setValue("");
            }
            //查询
            function search() {
                var orderNO = trimStr(mini.get("txt_OrderNO").getValue());
                var guaranteeNO = trimStr(mini.get("txt_GuaranteeNO").getValue());
                var buyerFullName = trimStr(mini.get("txt_BuyerFullName").getValue());
                var orderDate = trimStr(mini.get("txt_OrderDate").getFormValue());
                var isDel = trimStr(mini.get("txt_IsDel").getValue());
                grid.load({ orderNO: orderNO, guaranteeNO: guaranteeNO, buyerFullName: buyerFullName, orderDate: orderDate, isDel: isDel });
            }
            $("#txt_OrderNO").bind("keydown", function (e) {
                if (e.keyCode == 13) {
                    search();
                }
            });
            $("#txt_GuaranteeNO").bind("keydown", function (e) {
                if (e.keyCode == 13) {
                    search();
                }
            });
            $("#txt_BuyerFullName").bind("keydown", function (e) {
                if (e.keyCode == 13) {
                    search();
                }
            });
            $("#txt_OrderDate").bind("keydown", function (e) {
                if (e.keyCode == 13) {
                    search();
                }
            });
            $("#txt_IsDel").bind("keydown", function (e) {
                if (e.keyCode == 13) {
                    search();
                }
            });
            //导出表格
            function ExportExcel() {
                var columns = grid.getBottomColumns();

                function getColumns(columns) {
                    columns = columns.clone();
                    for (var i = columns.length - 1; i >= 0; i--) {
                        var column = columns[i];
                        if (!column.field) {
                            columns.removeAt(i);
                        } else {
                            var c = { header: column.header, field: column.field };
                            columns[i] = c;
                        }
                    }
                    return columns;
                }
                var columns = getColumns(columns);
                var json = mini.encode(columns);
                document.getElementById("excelData").value = json;
                // 隐藏域
                var orderNO = mini.get("txt_OrderNO").getValue();
                document.getElementById("orderNOHidden").value = orderNO;

                var guaranteeNO = mini.get("txt_GuaranteeNO").getValue();
                document.getElementById("guaranteeNOHidden").value = guaranteeNO;

                var buyerFullName = mini.get("txt_BuyerFullName").getValue();
                document.getElementById("buyerFullNameHidden").value = buyerFullName;

                var orderDate = mini.get("txt_OrderDate").getFormValue();
                document.getElementById("orderDateHidden").value = orderDate;

                var isDel = mini.get("txt_IsDel").getValue();
                document.getElementById("isDelHidden").value = isDel;
                var excelForm = document.getElementById("excelForm");
                excelForm.submit();
            }
            
        </script>
</body>
</html>
